package com.crm.model.jdao;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import com.crm.model.pojo.Customer;
import com.crm.model.pojo.SalesOpportunity;
import com.crm.model.pojo.User;



public interface IUserDAO extends CrudRepository<User, Integer>{
	
	/**
	 * 查询用户
	 * @param begin
	 * @param ends
	 * @return
	 */
	public List<User> findByuIdBetween(Integer begin,Integer ends); 
	
	/*@Query("SELECT p FROM Users p")
	public List<User> findAll();*/
	
	/**
	 * 
	 */
	 /**
	  * 要查找该用户下的员工,没有则查找当前登录用户,暂时采用模糊查询
	  * @param custName
	  * @return
	  */
	 @Query(value = "select * from users  where u_name like  CONCAT('%',:uName,'%') Limit 4",nativeQuery = true)
	 List<User> findByUNameLike(@Param("uName") String uName);
	 
		/**
		 * 带条件的分页，查询所有用户信息
		 * @param <T>
		 * @return
		 * 
		 */	 
	 Page<User> findAll(Specification<User> spec,Pageable pageable);
	
	/**
	 * 根据用户id查询
	 * @param uName
	 * @return
	 */
	public User findByUId(Integer uId); 
	


}


